<?php

/**
 * @author Tuong Tran <tuong.tran@outlook.com>
 */
class PageController extends Controller {

    /**
     * allow view post
     * @param type $alias
     */
    public function actionView($alias) {
        //get model with post type
        $model = Post::model()->find('`post_type` = :type AND `alias` = :alias', array(
          ':type' => 'page',
          ':alias' => $alias
        ));

        if (!$model) {
            //404
            throw new CHttpException(404, 'Page was not exists!');
        }

        //seo support
        $this->description = $model->meta_description;
        $this->keywords = $model->meta_keywords;

        //render layout
        $this->render('view', array(
          'model' => $model
        ));
    }

}
